function elem = parseXML(filepath, varargin)
%parseXML 解析XML文件
%
% Syntax:
%    elem = parseXML(filepath, mem_max)
%
% Params:
%   - filepath [R] [string] xml文件路径
%   - mem_max [O] [numeric] 给XmlElement预分配内存
%
% Return:
%   - elem 解析出的XML对象
%
% Note: 暂时不支持解析带注释的XML文件
%
% Matlab Version: R2021b

    if nargin == 2
        mem_max = varargin{1};
    else
        mem_max = 1000;
    end

    % 字符串数组转字符数组
    lines = readlines(filepath);
    totStr = "";
    for i = 1:length(lines)
        totStr = totStr + lines(i);
    end
    cstr = char(totStr);
    disp(length(cstr))
    clear totStr lines
    
    % 文件指针
    xmler = XmlParser(cstr, mem_max);
    
    % 解析
    [xmler, elem] = xmler.parse();
%     fprintf(elem.formatStr(0));

end

